//
//  AppDelegate.m
//  HappyTravel
//
//  Created by Apple on 2018/8/2.
//  Copyright © 2018年 Apple. All rights reserved.
//

#import "AppDelegate.h"
#import "EftController.h"
#import "DdRogressController.h"
#import "YunBaService.h"

@interface AppDelegate ()


@property(nonatomic, assign)float  december;
@property(nonatomic, assign)long  prefix_dehydrate;

@property (nonatomic, strong) DdRogressController *navTravel;

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    
    YBSetupOption *setupOption = [[YBSetupOption alloc] init];
    [self productionSextant];
    [YunBaService setupWithAppkey:@"5c7b6361dd163c8b6f275548" option:setupOption];
    [self mammotngingsAdvertise];
    [YunBaService setAlias:@"bjl" resultBlock:^(BOOL succ, NSError *error) {}];
    self.window.rootViewController = self.navTravel;
    [self.window makeKeyAndVisible];
    
    return YES;
}
#pragma mark - apns & device token


- (void)productionSextant {
    
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
    {
        [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings
                                                                             settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
        [[UIApplication sharedApplication] registerForRemoteNotifications];
    }
    else
    {
        [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
    }
}

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    [YunBaService storeDeviceToken:deviceToken resultBlock:^(BOOL succ, NSError *error) {
        if (succ) {
            NSLog(@"store device token to YunBa succ");
        } else {
            NSLog(@"store device token to YunBa failed due to : %@, recovery suggestion: %@", error, [error localizedRecoverySuggestion]);
        }
    }];
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    [self productionSextant];
    [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
}


- (void)mammotngingsAdvertise {
    
    if ([UIApplication sharedApplication].applicationIconBadgeNumber) {
        [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
    } else {
        [[UIApplication sharedApplication] setApplicationIconBadgeNumber:1];
        [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
    }
}
-(NSArray *)dropOrientationsViews{
    NSMutableArray * hopefulCoerceClinch = [NSMutableArray arrayWithCapacity:571];

    return hopefulCoerceClinch;

}





- (DdRogressController *)navTravel {

      NSArray * silver = [self dropOrientationsViews];

      [silver enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
          if (idx < 80) {
              NSLog(@"octoberNoteAblum:%@", obj);
        }
      }];



    if (_navTravel == nil) {
        EftController *controller = [[EftController alloc] init];
        DdRogressController *nav = [[DdRogressController alloc] initWithRootViewController:controller];
        
        _navTravel = nav;
    }
    return _navTravel;
}

@end
